from django.contrib import admin
from booktest.models import BookInfo, HeroInfo, PicTest, AreaInfo, GoodsInfo


# 自定义模型管理类
class BookInfoAdmin(admin.ModelAdmin):
	"""图书模型管理类"""
	list_display = ['id', 'title', 'bread', 'bpub_date']  # 需要显示的列名
	list_per_page = 5  # 指定每页显示的条数
	# actions_on_bottom = True
	list_filter = ['btitle']  # 列出可供选择的过滤
	search_fields = ['btitle']  # 指定搜索项
	# fields = ['bpub_date', 'bread']  # 详情页展示 也即可编辑区
	fieldsets = (
		('基本', {'fields': ['btitle']}),
		('高级', {'fields': ['bread']}),
	)  # 分组


class HeroInfoAdmin(admin.ModelAdmin):
	list_display = ['id', 'hname', 'hcomment']


class PicTestAdmin(admin.ModelAdmin):
	pass


class AreaStackedInline(admin.StackedInline):
	model = AreaInfo
	extra = 2


@admin.register(GoodsInfo)
class GoodsInfoAdmin(admin.ModelAdmin):
	list_display = ['id']


@admin.register(AreaInfo)
class AreaInfoAdmin(admin.ModelAdmin):
	list_display = ['id', 'addr', 'p_addr']
	list_per_page = 15
	search_fields = ['addr']  # 指定搜索项
	# list_filter = ['province']
	inlines = [AreaStackedInline]


# ordering = ['+id']


# Register your models here.
admin.site.register(BookInfo, BookInfoAdmin)
admin.site.register(HeroInfo, HeroInfoAdmin)
admin.site.register(PicTest, PicTestAdmin)
# admin.site.register(AreaInfo, AreaInfoAdmin)
